﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TaskBoardProject
{
    /// <summary>
    /// Description of Person class
    /// </summary>
    class Person
    {
        /// <summary>
        /// Property with person's last name.
        /// </summary>
        public string LastName { get; set; }
        /// <summary>
        /// Property with person's first name.
        /// </summary>
        public string FirstName { get; set; }

        public Person()
        {
            this.LastName = "Doe";
            this.FirstName = "John";
        }

        public Person(string fullName)
        {
            if (fullName.Length >= 3 && fullName.Contains(' '))
            {
                string[] temp = fullName.Split(' ');
                this.LastName = temp[0];
                this.FirstName = temp[1];
            }
            else 
            {
                this.LastName = "Doe";
                this.FirstName = "John";
            }
        }

        public Person(string lastName, string firstName)
        {
            if (lastName.Length > 0)
                this.LastName = lastName;
            else this.LastName = "Doe";
            if (firstName.Length > 0)
                this.FirstName = firstName;
            else this.FirstName = "John";
        }

        public override string ToString()
        {
            //return "Last name: "+LastName+"\nFirst name: "+FirstName;
            return LastName + " " + FirstName;
        }

        public override bool Equals(object obj)
        {
            Person temp = obj as Person;
            if (this.LastName.Equals(temp.LastName) && this.FirstName.Equals(temp.FirstName))
                return true;
            else return false;
        }

        public override int GetHashCode()
        {
            return base.GetHashCode();
        }

        /// <summary>
        /// Overrided operator == for Person
        /// </summary>
        /// <param name="firstPerson">first person</param>
        /// <param name="secondPerson">second person</param>
        /// <returns>Return true if first person equals to second person; false if  first person doesn't equals to person</returns>
        //public static bool operator ==(Person firstPerson, Person secondPerson)
        //{
        //    return firstPerson.Equals(secondPerson);
        //}

        /// <summary>
        /// Overrided operator != for Person
        /// </summary>
        /// <param name="firstPerson">first person</param>
        /// <param name="secondPerson">second person</param>
        /// <returns>Return false if first person equals to second person; true if  first person doesn't equals to person</returns>
        //public static bool operator !=(Person firstPerson, Person secondPerson)
        //{
        //    return !firstPerson.Equals(secondPerson);
        //}
    }
}
